import java.util.Scanner;

public class test4 {
    //洛谷 P9240 [蓝桥杯 2023 省 B] 冶炼金属
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] arr = new int[n][2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                arr[i][j] =scan.nextInt();
            }
        }

        int min = 1;

        while (!Istrue(arr,min)){

            min++;
        }
        System.out.println(min);

        while (Istrue(arr,min+1)){

            min++;
        }

        System.out.println(min);
    }

    public static boolean Istrue(int[][] arr , int num){
        for (int i = 0; i < arr.length; i++) {
            if(arr[i][0] / num != arr[i][1]){
                return false;
            }
        }
        return true;
    }
}
